package ada.com.uhotel.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import ada.com.uhotel.R;

import static ada.com.uhotel.R.attr.title;

/**
 * Created by cng19 on 2017/8/20.
 */

public class HlaView extends LinearLayout {
    public HlaView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    EditText leftText;
    TextView leftView;
    EditText rightText;
    TextView rightView;

    private void init(Context context, AttributeSet attrs) {
        LayoutInflater.from(context).inflate(R.layout.widget_hla, this);
        leftText = (EditText) findViewById(R.id.editText);
        leftView = (TextView) findViewById(R.id.textView);
        rightText = (EditText) findViewById(R.id.editRightText);
        rightView = (TextView) findViewById(R.id.textRightView);

        final TypedArray a = getContext().obtainStyledAttributes(
                attrs, R.styleable.WidgetHla);
        String left = a.getString(R.styleable.WidgetHla_leftLabel);
        if (left != null) {
            leftView.setText(left);
        }
        String right = a.getString(R.styleable.WidgetHla_rightLabel);
        if (right != null) {
            rightView.setText(right);
        }
    }

    public boolean check() {
        if (leftText.getText().toString().equals(rightText.getText().toString())) {
            return true;
        } else {
            return false;
        }
    }
}
